/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-04-24 18:43:39
 * @LastEditTime: 2024-04-24 19:04:32
 * @FilePath: /steel_live/src/routers/match.ts
 */
import { IRoute, RouteObject } from "./router.types";
//匹配路由信息
export const matchRoute = (pathname: string, routes: IRoute[] = []): RouteObject | IRoute => {
    let result = {};
    for(let item of routes){
        if(item.path==pathname){
            return item;
        }
        if(item.children?.length){
            const res = matchRoute(pathname,item.children);
            if(Object.keys(res).length){
                return res;
            }
        }
    }
    return result;
}